Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: Use DataSources in ACLs area #7681

Merged
merged 6 commits into from
Apr 22, 2020
Merged

Conversation

johncowen
Copy link
Contributor

Following #7334 we noticed that our event sources were no longer being cleanup correctly.

Our new style DataSources use Ember Components instead of Ember Proxies and are much more flexible and simpler to use. The main difference being DataSources automatically clean up when they are removed from the page or removed from display (depending if they use loading="lazy" or not)

This uses DataSources in the ACLs area, mainly to load in datacenters in the forms/modals where we use them - and is partly where the idea for IntersectionObserver backed DataSources came from.

A few more advantages here:

  1. We only make additional calls to the datacenters API when you open the 'Scoped by datacenters' options, if you never open it we don't make the call.
  2. Our policy/role selector components are now backed by blocking queries. If you add a policy or role elsewhere, it will immediately pop-in to the policy/role select menu.
  3. Our Datasource/Blocking query support keeps BlockingQueries open until they time out, or we max out our HTTP request restriction. That means they are reused between different instances of the same component in a page, or potentially across pages. This makes for instantaneous loading in some areas.

There is one place where we continue to use our old style EventSources, which we plan to swap out for our new <DataSink /> component further down the line.

We unfortunately and very reluctantly commented out an assertion in a test here. The assertion depends on the DataSource being within the viewport, which you can never guarantee in our test runner (due to skipped tests and size of the window etc etc).

We tried a few methods to improve this mainly around automatically scrolling to about to be clicked dom elements - following the thinking that in order to click something in must first be in the viewport. In the end we decided that this wasn't the right way to solve the problem, and it would be better to somehow provide mockable functionality for dom.isInViewport, and potentially a test step to 'pretend' that a DataSource is in the viewport.

The latter approach probably needs more in-depth work and before that, thinking through properly. So we went with the comment in order to move forwards and come back at a later date 😿

@johncowen johncowen added the theme/ui Anything related to the UI label Apr 21, 2020
@johncowen johncowen requested a review from a team April 21, 2020 18:18
Copy link
Contributor

@kaxcode kaxcode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ LGTM

@johncowen johncowen merged commit ccfad0d into ui-staging Apr 22, 2020
@johncowen johncowen deleted the ui/feature/acls-data-sources branch April 22, 2020 16:30
johncowen added a commit that referenced this pull request Apr 30, 2020
* ui: Use Datasource for loading related data in ACLs area

* ui: Use more manual cleanup for Controller event-sources

* Update reconcile to use nspace and add SyncTime to role/policy

* Use the correct value for nspace and dc (the one from the item itself)

* Remove the // check, we no longer need it. Add some TODO
kaxcode pushed a commit that referenced this pull request May 11, 2020
* ui: Use Datasource for loading related data in ACLs area

* ui: Use more manual cleanup for Controller event-sources

* Update reconcile to use nspace and add SyncTime to role/policy

* Use the correct value for nspace and dc (the one from the item itself)

* Remove the // check, we no longer need it. Add some TODO
johncowen added a commit that referenced this pull request May 12, 2020
* ui: Use Datasource for loading related data in ACLs area

* ui: Use more manual cleanup for Controller event-sources

* Update reconcile to use nspace and add SyncTime to role/policy

* Use the correct value for nspace and dc (the one from the item itself)

* Remove the // check, we no longer need it. Add some TODO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/ui Anything related to the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants